package com.mangguo.tingjian.activity.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mangguo.tingjian.activity.dto.ActivityLuckResult;
import com.mangguo.tingjian.activity.entity.DwLuckUserResultApp;
import com.mangguo.tingjian.activity.mapper.DwLuckUserResultAppMapper;
import com.mangguo.tingjian.activity.service.IDwLuckUserResultAppService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 中奖汇总 服务实现类
 * </p>
 *
 * @author auto
 * @since 2019-11-29
 */
@Service
public class DwLuckUserResultAppServiceImpl extends ServiceImpl<DwLuckUserResultAppMapper, DwLuckUserResultApp> implements IDwLuckUserResultAppService {

    @Resource
    private DwLuckUserResultAppMapper dwLuckUserResultMapper;

    @Override
    public ActivityLuckResult getResultBySubChannel(String subChannel){
        if(StringUtils.isBlank(subChannel)){
            return null;
        }
        DwLuckUserResultApp condition = new DwLuckUserResultApp();
        condition.setActivityId(subChannel);
        DwLuckUserResultApp dwLuckUserResultApp = dwLuckUserResultMapper.selectOne(new QueryWrapper<>(condition));
        ActivityLuckResult activityLuckResult = new ActivityLuckResult();
        if(dwLuckUserResultApp != null){
            BeanUtils.copyProperties(dwLuckUserResultApp, activityLuckResult);
        }
        return activityLuckResult;
    }

}
